<?php
namespace soa\express\shop;
use soa\client;


/**
 * Class branch
 * getParentBranchCodeById          返回指定ID的上级网点编号
 * getParentBranchCodeByCode        返回指定网点编号的上级网点编号
 * getSubBranchesById               返回指定ID下面的子网点信息
 * getSubBranchesByCode             返回指定网点编号下面的子网点信息
 * getBranchById                    返回指定ID的网点的官方信息
 * getBranchByCode                  返回指定网点编号的网点的官方信息
 * idToCode                         返回指定ID的网点的网点编号
 * codeToId                         返回指定网点编号的网点的Id
 */

class branch extends client
{
    /**
     * 服务地址
     * @var string
     */
    public $service_url = 'http://express.core.kuaidihelp.com/';

    /**
     * 服务名称
     * @var string
     */
    protected $service_name = 'kuaidihelp_express';

    /**
     * 返回指定ID的上级网点编号
     * @param $indexShopId 网点快宝id
     * @param string $brand
     * @return bool|null|string
     */
    public function __construct()
    {
        //branch服務遷移到soa\BasicInfo
        return '';
    }

    public function getParentBranchCodeById($indexShopId,$brand='')
    {
        if($indexShopId)
        {
            $url = 'v1/branch/info/getParentBranchCodeById';
            $param['index_shop_id'] = $indexShopId;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return '';
    }

    /**
     * 返回指定网点编号的上级网点编号
     * @param $branchCode 网点编号
     * @param string $brand
     * @return bool|null|string
     */
    public function getParentBranchCodeByCode($branchCode,$brand='')
    {
        if($branchCode)
        {
            $url = 'v1/branch/info/getParentBranchCodeByCode';
            $param['BranchCode'] = $branchCode;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return '';
    }

    /**
     * 返回指定ID的上级网点ID
     * @param $indexShopId 网点快宝id
     * @param string $brand
     * @return bool|null|string
     */
    public function getParentBranchIDById($indexShopId,$brand='')
    {
        if($indexShopId)
        {
            $url = 'v1/branch/info/getParentBranchIDById';
            $param['index_shop_id'] = $indexShopId;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return '';
    }

    /**
     * 返回指定网点编号的上级网点ID
     * @param $branchCode 网点编号
     * @param string $brand
     * @return bool|null|string
     */
    public function getParentBranchIDByCode($branchCode,$brand='')
    {
        if($branchCode)
        {
            $url = 'v1/branch/info/getParentBranchIDByCode';
            $param['BranchCode'] = $branchCode;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return '';
    }

    /**
     * 返回指定ID下面的子网点信息
     * @param $indexShopId 网点快宝id
     * @param string $brand
     * @return bool|null|string
     */
    public function getSubBranchesById($indexShopId,$brand='')
    {
        if($indexShopId)
        {
            $url = 'v1/branch/info/getSubBranchesById';
            $param['index_shop_id'] = $indexShopId;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return [];
    }


    /**
     * 返回指定网点编号下面的子网点信息
     * @param $branchCode 网点编号
     * @param string $brand
     * @return bool|null|string
     */
    public function getSubBranchesByCode($branchCode,$brand='')
    {
        if($branchCode)
        {
            $url = 'v1/branch/info/getSubBranchesByCode';
            $param['BranchCode'] = $branchCode;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return [];
    }

    /**
     * 返回指定ID的网点的官方信息
     * @param $indexShopId   网点快宝id
     * @param string $brand
     * @return array|bool|null
     */
    public function getBranchById($indexShopId,$brand='')
    {
        if($indexShopId)
        {
            $url = 'v1/branch/info/getBranchById';
            $param['index_shop_id'] = $indexShopId;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return [];
    }

    /**
     * 返回指定网点编号的网点的官方信息
     * @param $branchCode   网点编号
     * @param string $brand
     * @return array|bool|null
     */
    public function getBranchByCode($branchCode,$brand='')
    {
        if($branchCode)
        {
            $url = 'v1/branch/info/getBranchByCode';
            $param['BranchCode'] = $branchCode;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return [];
    }

    /**
     * 返回指定ID的网点的网点编号
     * @param $indexShopId   网点快宝id
     * @param string $brand
     * @return array|bool|null
     */
    public function idToCode($indexShopId,$brand='')
    {
        if($indexShopId)
        {
            $url = 'v1/branch/info/idToCode';
            $param['index_shop_id'] = $indexShopId;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return [];
    }

    /**
     * 返回指定网点编号的网点的Id
     * @param $branchCode   网点编号
     * @param string $brand
     * @return array|bool|null
     */
    public function codeToId($branchCode,$brand='')
    {
        if($branchCode)
        {
            $url = 'v1/branch/info/codeToId';
            $param['BranchCode'] = $branchCode;
            if(!empty($brand))
                $param['brand'] = $brand;
            return $this->get($url, $param);
        }
        else
            return [];
    }

    /**
     * 返回sto指定网点编号所属的独立网点
     * @param $branchCode 网点编号
     * @return bool|null|string
     */
    public function getStoParentBranchByCode($branchCode)
    {
        if($branchCode)
        {
            $url = 'v1/branch/info/getStoParentBranchByCode';
            $param['BranchCode'] = $branchCode;
            $param['brand'] = 'sto';
            return $this->get($url, $param);
        }
        else
            return '';
    }

}